<template>
  <div id="radar-graph"></div>
</template>

<script>
import * as echarts from "echarts/core";
import { TitleComponent, LegendComponent } from "echarts/components";
import { RadarChart } from "echarts/charts";
import { CanvasRenderer } from "echarts/renderers";
echarts.use([TitleComponent, LegendComponent, RadarChart, CanvasRenderer]);
export default {
  name: "Radar",
  /**
   *  {
              value: [],
              name: "个人得分",
            },
            {
              value: [],
              name: "平均得分",
            },
   */
  props: ["radarData"],
  mounted() {
    const chartDom = document.getElementById("radar-graph");
    const myChart = echarts.init(chartDom);
    const option = {
      title: {
        text: "综合评分",
      },
      legend: {
        data: ["个人得分", "平均得分"],
      },
      radar: {
        indicator: [
          { name: "操作技能掌握", max: 100 },
          { name: "整体能力", max: 100 },
          { name: "参训总体绩效", max: 100 },
          { name: "原理知识掌握", max: 100 },
          { name: "整体素质", max: 100 },
          { name: "个人学习情况", max: 100 },
        ],
      },
      series: [
        {
          name: "个人得分 vs 平均得分",
          type: "radar",
          data: [
            {
              value: [],
              name: "个人得分",
            },
            {
              value: [],
              name: "平均得分",
            },
          ],
        },
      ],
    };
    option.series[0].data = this.radarData;

    option && myChart.setOption(option);
  },
};
</script>

<style lang='less' scoped>
#radar-graph {
  width: 100%;
  height: 100%;
}
</style>